Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: -string->double for cljs shouldn't allow trailing garbage #942

Merged
merged 2 commits into from
Sep 1, 2023

Conversation

opqdonut
Copy link
Member

@opqdonut opqdonut commented Sep 1, 2023

(js/parseFloat "1.2abba") ==> 1.2

This was a difference between clj and cljs behaviour, but didn't have
a test.

Potentially a breaking change since somebody could've unknowingly
relied on this.

(js/parseFloat "1.2abba") ==> 1.2

This was a difference between clj and cljs behaviour, but didn't have
a test.

Potentially a breaking change since somebody could've unknowingly
relied on this.
@@ -69,7 +69,7 @@
(defn -string->double [x]
(if (string? x)
(try #?(:clj (Double/parseDouble x)
:cljs (let [x' (js/parseFloat x)] (if (js/isNaN x') x x')))
:cljs (let [x' (js/Number x)] (if (js/isNaN x') x x')))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or should we use cljs.core/parse-double & clojure.core/parse-double?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a commit that switches to parse-double. note that parse-double was introduced recently in clojure(script) 1.11

@opqdonut
Copy link
Member Author

opqdonut commented Sep 1, 2023

Merging this despite the 1.10 vs 1.11 question. Tests don't pass currently on 1.10 anyway, see #943

@opqdonut opqdonut merged commit 21dcd4e into master Sep 1, 2023
10 checks passed
@opqdonut opqdonut deleted the fix-js-double-decode branch September 1, 2023 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants